<?php

namespace App\Http\Controllers;

use App\Model\Hb;
use Illuminate\Http\Request;

class IndexController extends Controller
{
    public function index(Request $request)
    {

        if($request->isMethod('post')){
            $data = $request->get('data');
            if(empty($data['content'])){
                return redirect()->back();
            }
            $data['username'] = 'hb';
            $content = Hb::firstOrCreate(['username'=>'hb']);
            $content->content = $data['content'];
            $content->save();

        }
        $content = Hb::where('username','hb')->first();
        return view('index',compact('content'));
    }
    //
}
